﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace HigLabo.Net.Twitter
{
    public partial class TwitterClient
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="values"></param>
        /// <param name="callback"></param>
        public void LookupUsers(Int64[] values, Action<UserCollection> callback)
        {
            StringBuilder sb = new StringBuilder(256);
            for (int i = 0; i < values.Length; i++)
            {
                sb.Append(values[i]);
                if (i < values.Length - 1)
                {
                    sb.Append(",");
                }
            }
            var cm = new LookupUserCommand();
            cm.UserID = sb.ToString();
            this.LookupUsers(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="values"></param>
        /// <param name="callback"></param>
        public void LookupUsers(String[] values, Action<UserCollection> callback)
        {
            StringBuilder sb = new StringBuilder(256);
            for (int i = 0; i < values.Length; i++)
            {
                sb.Append(values[i]);
                if (i < values.Length - 1)
                {
                    sb.Append(",");
                }
            }
            var cm = new LookupUserCommand();
            cm.ScreenName = sb.ToString();
            this.LookupUsers(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void LookupUsers(LookupUserCommand command, Action<UserCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Users.LookupUrl, command
                , json => callback(new UserCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="query"></param>
        /// <param name="callback"></param>
        public void SearchUsers(String query, Action<UserCollection> callback)
        {
            this.SearchUsers(new SearchUserCommand() { Query = query }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void SearchUsers(SearchUserCommand command, Action<UserCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Users.SearchUrl, command
                , json => callback(new UserCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void ShowUser(Int64 id, Action<User> callback)
        {
            this.ShowUser(new ShowUserCommand() { UserID = id }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="screenName"></param>
        /// <param name="callback"></param>
        public void ShowUser(String screenName, Action<User> callback)
        {
            this.ShowUser(new ShowUserCommand() { ScreenName = screenName }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void ShowUser(ShowUserCommand command, Action<User> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Users.ShowUrl, command
                , json => callback(new User(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void GetContributees(Int64 id, Action<UserCollection> callback)
        {
            this.GetContributees(new GetContributeesCommand() { UserID = id }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="screenName"></param>
        /// <param name="callback"></param>
        public void GetContributees(String screenName, Action<UserCollection> callback)
        {
            this.GetContributees(new GetContributeesCommand() { ScreenName = screenName }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetContributees(GetContributeesCommand command, Action<UserCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Users.ContributeesUrl, command
                , json => callback(new UserCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void GetContributors(Int64 id, Action<UserCollection> callback)
        {
            this.GetContributors(new GetContributorsCommand() { UserID = id }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="screenName"></param>
        /// <param name="callback"></param>
        public void GetContributors(String screenName, Action<UserCollection> callback)
        {
            this.GetContributors(new GetContributorsCommand() { ScreenName = screenName }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetContributors(GetContributorsCommand command, Action<UserCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Users.ContributorsUrl, command
                , json => callback(new UserCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void GetProfileBanner(Int64 id, Action<BannerInfo> callback)
        {
            this.GetProfileBanner(new GetProfileBannerCommand() { UserID = id }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="screenName"></param>
        /// <param name="callback"></param>
        public void GetProfileBanner(String screenName, Action<BannerInfo> callback)
        {
            this.GetProfileBanner(new GetProfileBannerCommand() { ScreenName = screenName }, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetProfileBanner(GetProfileBannerCommand command, Action<BannerInfo> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Users.GetProfileBannerUrl, command
                , json => callback(new BannerInfo(json)));
        }
    }
}
